<?php

namespace App\Http\Requests\Backend\Setting;

use Illuminate\Foundation\Http\FormRequest;

class SettingHomeInsuranceRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $method = $this->method();
        switch ($method){
            case 'POST':
                return [
                    'title' => 'required',
                    'subtitle' => 'required',
                    'button_name' => 'required',
                    'url_set' => 'bail|required|url',
                    'img_url' => 'required',
                ];
                break;
            case 'PUT':
                return [
                    'url_set' => 'url',
                ];
                break;
        }
    }

    public function messages()
    {
        return [
            'title.required' => '请传递标题',
            'subtitle.required' => '请传递福标题',
            'button_name.required' => '请设置按钮文字',
            'url_set.required' => '请传递链接',
            'url_set.url' => '请传递有效链接',
            'img_url.required' => '请传递图片链接',

        ];
    }
}
